package cn.bone.spring.jms01;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * Created by superbone on 2016/9/13.
 */
@Service
public class ConsumerMessageListener implements MessageListener{

    @JmsListener(destination="demo.test01")
    public void onMessage(Message message) {
        TextMessage msg = (TextMessage)message;
        try {
            System.out.println("接收到一个文本消息:"+msg.getText());
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}
